from django.db import models
from users.models import userInfo,userGroup
from cmdb.models import hostInfo
# Create your models here.
class projectInfo(models.Model):
    projectName = models.CharField(max_length=20,unique=True)
    projectDir = models.CharField(max_length=500)
    projecthost = models.ForeignKey(hostInfo)  # 关联的主机
    projectowner = models.ManyToManyField(userInfo,null=True,blank=True)  #授权的用户
    projectgrouper = models.ManyToManyField(userGroup,null=True,blank=True) # 授权的用户组
    ctime = models.DateTimeField(auto_now_add=True)
    uptime = models.DateTimeField(auto_now=True)
    def __str__(self):
        return self.projectName
    class Meta:
        verbose_name = '项目'
        verbose_name_plural = '项目'

class onlineDetail(models.Model):
    onlineCode = models.CharField(max_length=50,unique=True)
    onlineOwner = models.ForeignKey(userInfo)  # 上线操作人
    onlineproject = models.ForeignKey(projectInfo)
    onlineStatus = models.IntegerField(default=1)
    ctime = models.DateTimeField(auto_now_add=True)
    uptime = models.DateTimeField(auto_now=True)
    def __str__(self):
        return self.onlineCode

class element(models.Model):
    elementName = models.CharField(max_length=20,unique=True)
    elementHumanName = models.CharField(max_length=20)
    elementDesc = models.CharField(max_length=200)
    def __str__(self):
        return self.elementName

class deployTask(models.Model):
    taskName = models.CharField(max_length=20)
    taskDesc = models.CharField(max_length=200)
    def __str__(self):
        return self.taskName
class taskSchedu(models.Model):
    taskname = models.ForeignKey(deployTask)
    hostiport = models.CharField(max_length=50)
    elementList = models.CharField(max_length=500)